package com.jdym.back.controller;


import com.jdym.R;
import com.jdym.back.entity.Approval;
import com.jdym.back.service.ApprovalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 * 贷款审批 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-09-20
 */
@Api("审核管理")
@CrossOrigin
@RestController
@RequestMapping("/back/approval")
public class ApprovalController {

    @Autowired
    ApprovalService approvalService;

    //    根据ID值定位查询
    @GetMapping  ("/selectApproval/{id}")
    public R selectApproval(@PathVariable int  id){
        Approval approvals = approvalService.selectApproval(id);
        System.out.println("=====11111======="+approvals);
        return R.ok().data("approvals",approvals).message("审批成功") ;
    }


    //    审核意见回复
    @ApiOperation("获取银行的审核信息")
    @PostMapping("/updateApproval/{cobankId}/{approvalID}")
    public R updateApproval(@RequestParam("advise") String advise ,
                            @RequestParam("time") Date time,
                            @RequestParam("status")int status,
                            @PathVariable int approvalID,
                            @PathVariable int cobankId) {
        Approval approval = new Approval();
        approval.setApprovalId(approvalID);
        approval.setCobankId(cobankId);
        approval.setApprovalAdvise(advise);//审核意见
        approval.setApprovalTime(time);//审核日期
        approval.setApprovalStatus(status);//审核状态
        approvalService.getBaseMapper().updateById(approval);
        System.out.println("===银行ID===approvals======" + approval);
        return R.ok();
    }

}


